package OperationSystem.day1205File;

import java.io.*;

public class 从文件输入字符流中读文本内容 {
    public static void main(String[] args) throws IOException {
        try (InputStream is = new FileInputStream("有中文.txt")) {
            try (Reader reader = new InputStreamReader(is, "UTF-8")) {
                StringBuffer sb = new StringBuffer();
                /*while (true) {
                    int b = reader.read();
                    if (b == -1) {
                        break;
                    }
                    sb.append((char)b);
                }*/

                char[] buffer = new char[1];
                while (true) {
                    int len = reader.read(buffer);
                    if (len == -1) {
                        break;
                    }
                    sb.append(buffer, 0, len);
                }
                System.out.println(sb.toString());
            }
        }
    }
}
